package My
//
//import (
//	"context"
//	"encoding/json"
//	"errors"
//	"fmt"
//	"db2s/dataDispos"
//	"db2s/global"
//	"db2s/go-log/log"
//	"db2s/parDef"
//	"db2s/ref"
//	"reflect"
//	"strings"
//	"sync/atomic"
//)
//
//func newTimeTypeToFunc(colMap, columnName, asColumn string) (r string) {
//	switch colMap {
//	case "year-month-day":
//		r = fmt.Sprintf("date_format(%v,'%%Y-%%m-%%d') as `%v`", columnName, asColumn)
//	case "hour:minute:second":
//		r = fmt.Sprintf("date_format(%v,'%%H:%%i:%%s') as `%v`", columnName, asColumn)
//	case "year-month-day hour:minute:second":
//		r = fmt.Sprintf("date_format(%v,'%%Y-%%m-%%d %%H:%%i:%%s') as `%v`", columnName, asColumn)
//	case "hour:minute:second.milli(1)", "hour:minute:second.milli(2)", "hour:minute:second.milli(3)", "hour:minute:second.micro(1)", "hour:minute:second.micro(2)", "hour:minute:second.micro(3)", "hour:minute:second.nano(1)", "hour:minute:second.nano(2)", "hour:minute:second.nano(3)":
//		r = fmt.Sprintf("date_format(%v,'%%H:%%i:%%s.%%f') as `%v`", columnName, asColumn)
//	case "year":
//		r = fmt.Sprintf("date_format(%v,'%%Y') as `%v`", columnName, asColumn)
//	case "year-month-day hour:minute:second.milli(1)", "year-month-day hour:minute:second.milli(2)", "year-month-day hour:minute:second.milli(3)", "year-month-day hour:minute:second.micro(1)", "year-month-day hour:minute:second.micro(2)", "year-month-day hour:minute:second.micro(3)", "year-month-day hour:minute:second.nano(1)", "year-month-day hour:minute:second.nano(2)", "year-month-day hour:minute:second.nano(3)":
//		r = fmt.Sprintf("date_format(%v,'%%Y-%%m-%%d %%H:%%i:%%s.%%f') as `%v`", columnName, asColumn)
//	default:
//		r = fmt.Sprintf("date_format(%v,'%%Y-%%m-%%d %%H:%%i:%%s') as `%v`", columnName, asColumn)
//	}
//	return
//}
//func newFloatTypeToFunc(precision, scale int64, columnName, asColumn string) (r string) {
//	var decimal []string
//	if precision > 0 {
//		decimal = append(decimal, fmt.Sprintf("%v", precision))
//	}
//	if scale > 0 {
//		decimal = append(decimal, fmt.Sprintf("%v", scale))
//	}
//	if len(decimal) > 0 {
//		r = fmt.Sprintf("CAST(%v AS DECIMAL(%v)) as `%v`", columnName, strings.Join(decimal, ","), asColumn)
//	} else {
//		r = fmt.Sprintf("%v as `%v`", columnName, asColumn)
//	}
//	return
//}
//
//func newReadGisTypeToFunc(columnName, asColumn string) (r string) {
//	return fmt.Sprintf(" \n"+
//		"CASE \n    "+
//		"WHEN %v IS NOT NULL \n    "+
//		"THEN \n"+
//		"concat("+
//		"	ST_AsText(%v), '@STYPE:', ST_GeometryType(%v), ',','SRID:', ST_SRID(%v) , ',','AXIS:OGC'"+
//		") \n    "+
//		"ELSE NULL \n  "+
//		"END AS %v ",
//		columnName, columnName, columnName, columnName, asColumn)
//}
//
//func newTimeValueToFunc(colMap, value string) (r string) {
//	switch colMap {
//	case "year-month-day":
//		r = fmt.Sprintf("DATE_FORMAT(%s,'%%Y-%%m-%%d')", value)
//	case "hour:minute:second":
//		r = fmt.Sprintf("DATE_FORMAT(%s,'%%H:%%i:%%s')", value)
//	case "year-month-day hour:minute:second":
//		r = fmt.Sprintf("DATE_FORMAT(%s,'%%Y-%%m-%%d %%H:%%i:%%s')", value)
//	default:
//		r = fmt.Sprintf("DATE_FORMAT(%s,'%%Y-%%m-%%d %%H:%%i:%%s')", value)
//	}
//	return
//}
//func newDecimalTypeToFunc(columnName, asColumn string) (r string) {
//	r = fmt.Sprintf("0+CAST(%v as char)  as `%v`", columnName, asColumn)
//	return
//}
//func NewSpecialTypeToFunc(LockCol parDef.Encryption, colMap parDef.ColMetaMapS) (r string) {
//	asColumn := fmt.Sprintf("C%v", colMap.ColumnSeq)
//	var unlockFunc string
//	for _, v := range LockCol.Column {
//		if strings.EqualFold(v, colMap.ColumnName) && len(LockCol.UnlockFunc) > 0 {
//			unlockFunc = fmt.Sprintf("%v.%v(`%v`)", LockCol.Schema, LockCol.UnlockFunc, colMap.ColumnName)
//			break
//		}
//	}
//	if len(unlockFunc) == 0 {
//		unlockFunc = fmt.Sprintf("`%v`", colMap.ColumnName)
//	}
//	switch colMap.TypeBelong {
//	case "time", "timestamp":
//		return newTimeTypeToFunc(colMap.Type.ColTypeMap, unlockFunc, asColumn)
//	case "float", "double":
//		return newFloatTypeToFunc(colMap.Type.Precision, colMap.Type.Scale, unlockFunc, asColumn)
//	case "decimal":
//		return newDecimalTypeToFunc(unlockFunc, asColumn)
//	case "gis":
//		return newReadGisTypeToFunc(unlockFunc, asColumn)
//	default:
//		return fmt.Sprintf("%v as `%v`", unlockFunc, asColumn)
//	}
//}
//
//// NewSpecialCharValueToFunc 根据列的数据类型，将字符串值继续函数转换
//func NewSpecialCharValueToFunc(colMap parDef.ColMetaMapS, value string) (newValue string) {
//	newValue = strings.ReplaceAll(value, "'", "\\'")
//	switch colMap.TypeBelong {
//	case "time", "timestamp":
//		return newTimeValueToFunc(colMap.Type.ColTypeMap, newValue)
//	default:
//		switch {
//		case strings.EqualFold(colMap.ColumnName, "rowId"):
//			newValue = value
//		case strings.EqualFold(newValue, "NULL"):
//			newValue = value
//		}
//		return
//	}
//}
//func newHitSpecify(indexName, partitionName string) (hitIndexName string) {
//	//指定partition name会导致无法使用索引，进行全表扫描，且该sql为查询数据，已经通过索引列范围确定查询范围，所以不需要指定分区
//	if len(indexName) > 0 && !strings.EqualFold(partitionName, "single") && len(partitionName) > 0 {
//		hitIndexName = fmt.Sprintf(" /*+ index(T %v) */ ", indexName)
//	}
//	return
//}
//func newLeftStitching(s parDef.WhereGenerateInput) (l string) {
//	var whereLeft []string
//	for _, v := range func() []map[string]string {
//		if len(s.NewLeftDirection) > 0 {
//			return s.NewLeftDirection
//		}
//		return getAtomicValue(s.LeftDirection)
//	}() {
//		columnName, nLeftOk := v["columnName"]
//		columnDataLeft, cLeftOk := v["columnDataLeft"]
//		querySymbolLeft, qLeftOk := v["querySymbolLeft"]
//		if cLeftOk && qLeftOk && nLeftOk {
//			if strings.EqualFold(querySymbolLeft, "=") && strings.EqualFold(columnDataLeft, "NULL") { //处理等值null
//				whereLeft = append(whereLeft, fmt.Sprintf("`%s` %s %s", columnName, " IS ", columnDataLeft))
//			} else if strings.EqualFold(querySymbolLeft, ">") && strings.EqualFold(columnDataLeft, "NULL") {
//				whereLeft = append(whereLeft, fmt.Sprintf("`%s` %s %s", columnName, " IS NOT ", columnDataLeft))
//			} else {
//				whereLeft = append(whereLeft, fmt.Sprintf("`%s` %s %s", columnName, querySymbolLeft, NewSpecialCharValueToFunc(getSpecialColNameMetaMap(columnName, s.ColMetaMap), columnDataLeft)))
//			}
//		}
//	}
//	return strings.Join(whereLeft, " and ")
//}
//func getSpecialColNameMetaMap(name string, colMeta []parDef.ColMetaMapS) (r parDef.ColMetaMapS) {
//	for _, col := range colMeta {
//		if strings.EqualFold(col.ColumnName, name) {
//			return col
//		}
//	}
//	return
//}
//func newRightStitching(s parDef.WhereGenerateInput) string {
//	var whereRight []string
//	for _, v := range func() []map[string]string {
//		if len(s.NewRightDirection) > 0 {
//			return s.NewRightDirection
//		}
//		return getAtomicValue(s.RightDirection)
//	}() {
//		columnName, nRightOk := v["columnName"]
//		columnDataRight, cRightOk := v["columnDataRight"]
//		querySymbolRight, qRightOk := v["querySymbolRight"]
//		if cRightOk && qRightOk && nRightOk {
//			if strings.EqualFold(querySymbolRight, "=") && strings.EqualFold(columnDataRight, "NULL") {
//				whereRight = append(whereRight, fmt.Sprintf("`%s` %s %s", columnName, " IS ", columnDataRight))
//			} else if strings.EqualFold(querySymbolRight, ">") && strings.EqualFold(columnDataRight, "NULL") {
//				whereRight = append(whereRight, fmt.Sprintf("`%s` %s %s", columnName, " IS NOT ", columnDataRight))
//			} else {
//				whereRight = append(whereRight, fmt.Sprintf("`%s` %s %s", columnName, querySymbolRight, NewSpecialCharValueToFunc(getSpecialColNameMetaMap(columnName, s.ColMetaMap), columnDataRight)))
//			}
//		}
//	}
//	return strings.Join(whereRight, " and ")
//}
//func newWhereGenerate(whereSql string, s parDef.WhereGenerateInput) (ConditionSlice []string, err error) {
//	if len(whereSql) > 0 {
//		ConditionSlice = append(ConditionSlice, whereSql)
//		return
//	}
//	if v := newLeftStitching(s); len(v) > 0 {
//		ConditionSlice = append(ConditionSlice, v)
//	}
//	if v := newRightStitching(s); len(v) > 0 {
//		ConditionSlice = append(ConditionSlice, v)
//	}
//	return
//}
//func newOrderBY(s parDef.WhereGenerateInput) (res string, err error) {
//	var orderByColumn []string
//	if strings.EqualFold(s.NullConstraint, "null") {
//		return
//	}
//	var uniqOrderByColumn = make(map[string]int)
//	for _, v := range s.IndexColumn {
//		for _, v1 := range getAtomicValue(s.LeftDirection) {
//			if v2, ok := v1["columnName"]; ok {
//				if strings.EqualFold(v, v2) {
//					if _, ok2 := uniqOrderByColumn[v]; !ok2 {
//						uniqOrderByColumn[v]++
//						orderByColumn = append(orderByColumn, v)
//					}
//				}
//			}
//		}
//	}
//	if len(orderByColumn) > 0 {
//		return fmt.Sprintf("order by `%v`", strings.Join(orderByColumn, "`,`")), nil
//	}
//	return
//}
//func newResultCol(asSelectColumn []string, tableAS string) (r string) {
//	var l []string
//	for _, v := range asSelectColumn {
//		l = append(l, fmt.Sprintf("%v.`%v` ", tableAS, v))
//	}
//	return strings.Join(l, ",")
//}
//func newSelectCol(selectC []string) (r string) {
//	var selectIndexColumn []string
//	for _, v := range selectC {
//		selectIndexColumn = append(selectIndexColumn, fmt.Sprintf("\"%v\"", v))
//	}
//	return strings.Join(selectIndexColumn, ",")
//}
//func newOrderByNull(indexCol []string) (r string) {
//	return fmt.Sprintf(" order by `%v`", strings.Join(indexCol, "`,`"))
//}
//func newWhereSplicing(whereCondition []string) (r string) {
//	if len(whereCondition) > 0 {
//		return fmt.Sprintf(" and %v", strings.Join(whereCondition, " and "))
//	}
//	return
//}
//func getIndexColMetaCharset(parameter parDef.Parameter) (collation string, compareVal []string) {
//	switch parameter.Meta.(type) {
//	case map[string][]string:
//		for col, val := range parameter.Meta.(map[string][]string) {
//			for _, subCol := range parameter.Object.Index.ColumnMate {
//				if strings.EqualFold(col, subCol.ColumnName) {
//					collation = subCol.Collation
//					compareVal = val
//					break
//				}
//			}
//		}
//	}
//	return
//}
//func getColCharacterVarchar(parameter parDef.Parameter) (newCompareVal []string) {
//	var collation, compareVal = getIndexColMetaCharset(parameter)
//	for _, v := range compareVal {
//		var notNullVal = v
//		if strings.EqualFold(v, "<null>") {
//			notNullVal = "NULL"
//		}
//		newCompareVal = append(newCompareVal, fmt.Sprintf("'%v' COLLATE %v", notNullVal, collation))
//	}
//	return
//}
//func (rows RowsF) getInsertIntoColumnPrefix(ctx context.Context) (insertColumn [][]string, err error) {
//	var result global.Return
//	var event = "[getInsertIntoColumnPrefix]"
//	if result, err = rows.InsertAllCol(ctx); err != nil {
//		err = ref.ErrAddPrintf(event, err)
//		return
//	}
//	switch result.Result.(type) {
//	case [][]string:
//		insertColumn = result.Result.([][]string)
//	default:
//		err = ref.ErrAddPrintf(event, errors.New(fmt.Sprintf("type not match. curry type is %v", reflect.TypeOf(result.Result))))
//	}
//	return
//}
//func (rows RowsF) Prefix(ctx context.Context) (result global.Return, err error) {
//	var event = "[Prefix]"
//	var tableName, ignoreStr string
//	var insertColumn [][]string
//	defer func() {
//		if r := ref.RecoverPanic(event, recover()); err == nil && r != nil {
//			err = r
//		}
//	}()
//	return ctxDoneExecFunc(ctx, func() (global.Return, error) {
//		//"IGNORE" //timetimp类型 Incorrect datetime value: '2024-09-26 11:27:28 +0800 08:00' for column
//		if insertColumn, err = rows.getInsertIntoColumnPrefix(ctx); err != nil {
//			err = ref.ErrAddPrintf(event, err)
//			return result, err
//		}
//		var schema, table = getExecFuncParameterValueBase(ctx)
//		tableName = fmt.Sprintf(" `%v`.`%v` ", schema, table)
//		result.Result = fmt.Sprintf("%s ", fmt.Sprintf("INSERT %v INTO %v (`%s`) VALUES", ignoreStr, tableName, strings.Join(insertColumn[0], "`,`")))
//		if parDef.GetParameterValueAnyToBool(parDef.GetFuncParameterValue(ctx, "lobTableLogo")) {
//			var s1 []string
//			for i := 0; i < len(insertColumn[0]); i++ {
//				if strings.EqualFold(insertColumn[1][i], "gis") {
//					s1 = append(s1, "ST_GeomFromText(?, ?)")
//				} else {
//					s1 = append(s1, "?")
//				}
//			}
//			result.Result = fmt.Sprintf("INSERT INTO %v (`%s`) VALUES (%s)", tableName, strings.Join(insertColumn[0], "`,`"), strings.Join(s1, ","))
//		}
//		return result, nil
//	})
//}
//
//func (rows RowsF) writeFileDML(parameter parDef.Parameter) (result global.Return, err error) {
//	var event = "[writeFileDML]"
//	if parameter.ExecDML.FilePoint == nil {
//		return
//	}
//	if err = parameter.ExecDML.FilePoint.Write("", parameter.ExecDML.Sql); err != nil {
//		err = ref.ErrAddPrintf(event, err)
//		return
//	}
//	return
//}
//
//func (rows RowsF) connExecDML(parameter parDef.Parameter) (result global.Return, err error) {
//	//var event = "[connExecDML]"
//	//if result.TimeOut, result.Result, err = newExecUpdateSql(ExecSqlInputS{
//	//	Ss:           parameter,
//	//	Event:        event,
//	//	UpdateSqlStr: []string{parameter.ExecDML.Sql},
//	//}); err != nil {
//	//	err = ref.ErrAddPrintf(event, err)
//	//	return
//	//}
//	return
//}
//
//func (rows RowsF) ExecDML(parameter parDef.Parameter) (result global.Return, err error) {
//	var event = "[ExecDML]"
//	switch parameter.Options.RepairMethod {
//	case "file":
//		return rows.writeFileDML(parameter)
//	case "table":
//		return rows.connExecDML(parameter)
//	default:
//		err = ref.ErrAddPrintf(event, errors.New(fmt.Sprintf("The repair method was not matched. curry method is %v", parameter.Options.RepairMethod)))
//	}
//	return
//}
//
//func (rows RowsF) SelectIdxCol(parameter parDef.Parameter) (result global.Return, err error) {
//	var columnName, asColumnName []string
//	for _, i := range parameter.Object.IndexCol {
//		p := getSpecialColNameMetaMap(i, parameter.Object.Column)
//		asColumnName = append(asColumnName, fmt.Sprintf("C%v", p.ColumnSeq))
//		columnName = append(columnName, NewSpecialTypeToFunc(parameter.Object.LockCol, p))
//	}
//	result.Result = [][]string{columnName, asColumnName}
//	return
//}
//func (rows RowsF) SelectAllCol(parameter parDef.Parameter) (result global.Return, err error) {
//	var columnName, asColumnName []string
//	for _, v := range parameter.Object.Column {
//		asColumnName = append(asColumnName, fmt.Sprintf("C%v", v.ColumnSeq))
//		columnName = append(columnName, NewSpecialTypeToFunc(parameter.Object.LockCol, v))
//	}
//	result.Result = columnName
//	return
//}
//func (rows RowsF) InsertAllCol(ctx context.Context) (result global.Return, err error) {
//	var columnNameAndType [][]string
//	switch meta := parDef.GetFuncParameterValue(ctx, parDef.GetMetaParameterValue()); meta.(type) {
//	case []parDef.ColMetaMapS:
//		var columnName, columnType []string
//		for _, v := range meta.([]parDef.ColMetaMapS) {
//			columnName = append(columnName, v.ColumnName)
//			columnType = append(columnType, v.TypeBelong)
//		}
//		columnNameAndType = append(columnNameAndType, columnName, columnType)
//	}
//	result.Result = columnNameAndType
//	return
//}
//func (rows RowsF) StringValueCompare(parameter parDef.Parameter) (result global.Return, err error) {
//	var event = "[StringValueCompare]"
//	defer func() {
//		if r := recover(); r != nil {
//			err = errors.New(fmt.Sprintf("%v defer recover An exception was captured. abnormal is %v ", event, r))
//		}
//	}()
//	var newCompareVal = getColCharacterVarchar(parameter)
//	var execSql = []string{fmt.Sprintf("SELECT \n    "+
//		"CASE \n        "+
//		"WHEN %v < %v "+
//		"THEN '-1'\n        "+
//		"WHEN %v > %v "+
//		"THEN '1'\n        "+
//		"ELSE '0'\n    "+
//		"END AS comparison_result\n"+
//		"FROM dual",
//		newCompareVal[0], newCompareVal[1],
//		newCompareVal[0], newCompareVal[1])}
//	if result, err = forExecQuerySql(event, parameter, dataDispos.String, execSql); err != nil {
//		err = ref.ErrAddPrintf("Oracle.StringValueCompare", err)
//		return
//	}
//	if result.Result, err = stringAnyToInt64(result.Result); err != nil {
//		err = ref.ErrAddPrintf("Oracle.StringValueCompare", err)
//		return
//	}
//	return
//}
//
//func (rows RowsF) IndexPart(parameter parDef.Parameter) (result global.Return, err error) {
//	var (
//		event          = "[IndexPart]"
//		res            global.Return
//		selectCol      []string
//		selectColAs    []string
//		whereCondition []string
//		indexP         parDef.IndexPart
//	)
//	defer func() {
//		if r := recover(); r != nil {
//			err = errors.New(fmt.Sprintf("%v defer recover An exception was captured. abnormal is %v ", event, r))
//		}
//	}()
//	switch parameter.Meta.(type) {
//	case parDef.IndexPart:
//		indexP = parameter.Meta.(parDef.IndexPart)
//	default:
//		err = ref.ErrAddPrintf("MySQL.IndexPart", errors.New(fmt.Sprintf("type not matched. curry type is %v", reflect.TypeOf(parameter.Meta))))
//		return
//	}
//	if res, err = rows.SelectIdxCol(parameter); err != nil {
//		err = ref.ErrAddPrintf("MySQL.IndexPart", err)
//		return
//	} else if res.Result == nil {
//		return
//	} else {
//		selectCol, selectColAs = res.Result.([][]string)[0], res.Result.([][]string)[1]
//	}
//	if whereCondition, err = newWhereGenerate(parameter.Options.WhereSql, indexP.WhereGenerate); err != nil {
//		err = ref.ErrAddPrintf("MySQL.IndexPart", err)
//		return
//	}
//	if len(whereCondition) == 0 {
//		whereCondition = append(whereCondition, fmt.Sprintf("`%s` IS NOT NULL ", parameter.Object.IndexCol[0]))
//	}
//	var sqlText string
//	switch {
//	case parameter.Options.RowsLimit > 0:
//		sqlText = fmt.Sprintf("select %v from ( "+
//			"select %v "+
//			"from %v  "+
//			"%v %v "+
//			") A where 1= 1 "+
//			"%v limit %d,1",
//			newResultCol(selectColAs, "A"),
//			strings.Join(selectCol, ","),
//			tableObject(parameter.Object.Schema, parameter.Object.Table, parameter.Object.Partition),
//			newOrderByNull(parameter.Object.IndexCol), rowsLimitC(parameter.Options.RowsLimit),
//			newWhereSplicing(whereCondition),
//			atomic.LoadInt64(indexP.Limit.Pagination))
//	default:
//		sqlText = fmt.Sprintf("select %v "+
//			"from %v"+
//			"where 1 = 1 %v %v "+
//			"limit %d,1",
//			strings.Join(selectCol, ","),
//			tableObject(parameter.Object.Schema, parameter.Object.Table, parameter.Object.Partition),
//			newWhereSplicing(whereCondition),
//			newOrderByNull(parameter.Object.IndexCol),
//			atomic.LoadInt64(indexP.Limit.Pagination),
//		)
//	}
//	var execSql = []string{sqlText}
//	if result, err = forExecQuerySql(event, parameter, dataDispos.Map, execSql); err != nil {
//		err = ref.ErrAddPrintf("MySQL.IndexPart", err)
//	}
//	return
//}
//
//func (rows RowsF) SelectRowsSql(parameter parDef.Parameter) (result global.Return, err error) {
//	var (
//		res                       global.Return
//		w                         = []string{" "}
//		event                     = "[SelectRowsSql]"
//		selectCol, whereCondition []string
//		orderByCol                string
//		s                         parDef.IndexPart
//		indexP                    parDef.IndexPart
//	)
//	defer func() {
//		if r := recover(); r != nil {
//			err = errors.New(fmt.Sprintf("%v defer recover An exception was captured. abnormal is %v ", event, r))
//		}
//	}()
//	switch parameter.Meta.(type) {
//	case parDef.IndexPart:
//		indexP = parameter.Meta.(parDef.IndexPart)
//	default:
//		err = ref.ErrAddPrintf("MySQL.SelectRowsSql", errors.New(fmt.Sprintf("type not matched. curry type is %v", reflect.TypeOf(parameter.Meta))))
//		return
//	}
//	if res, err = rows.SelectAllCol(parameter); err != nil {
//		err = ref.ErrAddPrintf("MySQL.SelectRowsSql", err)
//		return
//	} else if res.Result == nil {
//		return
//	} else {
//		selectCol = res.Result.([]string)
//	}
//	whereCondition, err = newWhereGenerate(parameter.Options.WhereSql, indexP.WhereGenerate)
//	orderByCol, err = newOrderBY(s.WhereGenerate)
//	result.Result = fmt.Sprintf("select %v %v \n"+
//		"from %v %v \n"+
//		"where 1 = 1 %v \n"+
//		"%v",
//		newHitSpecify("", parameter.Object.Partition), strings.Join(selectCol, ","),
//		tableObject(parameter.Object.Schema, parameter.Object.Table, parameter.Object.Partition), specifyScn(parameter.Options.Scn),
//		strings.Join(append(w, whereCondition...), " and "),
//		orderByCol)
//	return
//}
//func (rows RowsF) ReadData(parameter parDef.Parameter) (result global.Return, err error) {
//	var event = "[ReadData]"
//	var execSql []string
//	defer func() {
//		if r := recover(); r != nil {
//			err = errors.New(fmt.Sprintf("%v defer recover An exception was captured. abnormal is %v ", event, r))
//		}
//	}()
//	if parameter.Meta == nil {
//		return
//	}
//	switch parameter.Meta.(type) {
//	case string:
//		execSql = append(execSql, parameter.Meta.(string))
//	case []string:
//		execSql = parameter.Meta.([]string)
//	default:
//		err = ref.ErrAddPrintf("MySQL.ReadData", errors.New(fmt.Sprintf("type not matched. curry type %v", reflect.TypeOf(parameter.Meta))))
//		return
//	}
//	if result, err = forExecQuerySql(event, parameter, dataDispos.GarthStringPointGarth, execSql); err != nil {
//		err = ref.ErrAddPrintf("MySQL.ReadData", err)
//		return
//	}
//	return
//}
//func (rows RowsF) ReadMiss(parameter parDef.Parameter) (result global.Return, err error) {
//	var (
//		event   = "[MySQL.ReadMiss]"
//		res     global.Return
//		execSql []string
//	)
//	defer func() {
//		if r := recover(); r != nil {
//			err = errors.New(fmt.Sprintf("%v defer recover An exception was captured. abnormal is %v ", event, r))
//		}
//	}()
//	if res, err = rows.SelectAllCol(parameter); err != nil {
//		err = ref.ErrAddPrintf(event, err)
//		return
//	}
//	if res.Result == nil {
//		log.MainLog().Warn(event, "no data to read")
//		return
//	}
//	execSql = append(execSql, fmt.Sprintf("select %v \n"+
//		"from %v "+
//		"where 1= 1 %v \n",
//		strings.Join(res.Result.([]string), ","),
//		tableObject(parameter.Object.Schema, parameter.Object.Table, parameter.Object.Partition),
//		rowsLimitC(parameter.Options.RowsLimit)))
//	log.MainLog().Debug(event, fmt.Sprintf(" sql is %v", execSql))
//	if result, err = forExecQuerySql(event, parameter, dataDispos.FlowAny, execSql); err != nil {
//		err = ref.ErrAddPrintf(event, err)
//		return
//	}
//	return
//}
//
//func newColNameLock(schema string, lockFunc string, columnVal string) (r string) {
//	r = fmt.Sprintf("%v", columnVal)
//	if len(lockFunc) > 0 {
//		r = fmt.Sprintf("%v.%v(%v)", schema, lockFunc, r)
//	}
//	return
//}
//func newNullValueActive(lob bool, s string, details string) (r string) {
//	switch {
//	case strings.EqualFold(s, "<null>"):
//		if lob { //json数据的null值在lob插入是nil
//			return fmt.Sprintf("<prepare nil>")
//		}
//		return fmt.Sprintf("NULL")
//	case strings.EqualFold(s, "<entry>") || len(s) == 0:
//		switch strings.ToLower(details) {
//		case "gis", "decimal", "int":
//			return fmt.Sprintf("NULL")
//		default:
//			if lob {
//				return fmt.Sprintf("<prepare entry>")
//			}
//			return fmt.Sprintf("''")
//		}
//	default:
//		return
//	}
//}
//func newGisWktValueCheck(gisVal parDef.GisValWkt, prefixSwitch bool) (prefix string, wkt []string, err error) {
//	return GeomJsonToWkt(gisVal, prefixSwitch)
//}
//func newGisPointStr(s string) (r string, err error) {
//	//ST_GeomFromText('POINT(116.3 39.9)', 4326)
//	defer func() {
//		if err != nil {
//			err = ref.ErrAddPrintf("newGisPointStr", err)
//		}
//	}()
//	var gisVal parDef.GisValWkt
//	var prefix string
//	var newWkt []string
//	if gisVal, err = jsonStrToGisValWkt(s); err != nil {
//		return
//	}
//	if prefix, newWkt, err = newGisWktValueCheck(gisVal, false); err != nil {
//		return
//	}
//	r = fmt.Sprintf("ST_GeomFromText('%v%v',%v)", prefix, strings.Join(newWkt, ","), gisVal.SRid)
//	return
//}
//func newGisMultiPointStr(s string) (r string, err error) {
//	//ST_GeomFromText('MULTIPOINT(10 10, 20 20, 30 30)', 4326)
//	var gisVal parDef.GisValWkt
//	var prefix string
//	var newWkt []string
//	if gisVal, err = jsonStrToGisValWkt(s); err != nil {
//		return
//	}
//	if prefix, newWkt, err = newGisWktValueCheck(gisVal, false); err != nil {
//		return
//	}
//	r = fmt.Sprintf("ST_GeomFromText('%v%v',%v)", prefix, strings.Join(newWkt, ","), gisVal.SRid)
//	return
//}
//func newGisLinestringStr(s string) (r string, err error) {
//	//ST_GeomFromText('LINESTRING(116.3 39.9, 116.4 39.9, 116.4 39.8, 116.3 39.8)', 4326)
//	var gisVal parDef.GisValWkt
//	var prefix string
//	var newWkt []string
//	if gisVal, err = jsonStrToGisValWkt(s); err != nil {
//		return
//	}
//	if prefix, newWkt, err = newGisWktValueCheck(gisVal, false); err != nil {
//		return
//	}
//	r = fmt.Sprintf("ST_GeomFromText('%v%v',%v)", prefix, strings.Join(newWkt, ","), gisVal.SRid)
//	return
//}
//func newGisMultiLinestringStr(s string) (r string, err error) {
//	//ST_GeomFromText('MULTILINESTRING((10 10, 20 20), (30 30, 40 40, 50 30), (60 60, 70 70))', 4326)
//	var gisVal parDef.GisValWkt
//	var newWkt, wktStr []string
//	if gisVal, err = jsonStrToGisValWkt(s); err != nil {
//		return
//	}
//	if _, newWkt, err = newGisWktValueCheck(gisVal, false); err != nil {
//		return
//	}
//	for _, v := range newWkt {
//		if strings.HasPrefix(v, "LINESTRING") {
//			wktStr = append(wktStr, strings.TrimPrefix(v, "LINESTRING"))
//		} else {
//			wktStr = append(wktStr, v)
//		}
//	}
//	r = fmt.Sprintf("ST_GeomFromText('MULTILINESTRING(%v)',%v)", strings.Join(wktStr, ","), gisVal.SRid)
//	return
//}
//func newGisPolygonStr(s string) (r string, err error) {
//	//ST_GeomFromText('POLYGON((116.3 39.9, 116.4 39.9, 116.4 39.8, 116.3 39.8, 116.3 39.9))', 4326)
//	var gisVal parDef.GisValWkt
//	var prefix string
//	var newWkt []string
//	if gisVal, err = jsonStrToGisValWkt(s); err != nil {
//		return
//	}
//	if prefix, newWkt, err = newGisWktValueCheck(gisVal, false); err != nil {
//		return
//	}
//	r = fmt.Sprintf("ST_GeomFromText('%v(%v)',%v)", prefix, strings.Join(newWkt, ","), gisVal.SRid)
//	return
//}
//func jsonStrToGisValWkt(s string) (gisVal parDef.GisValWkt, err error) {
//	if err = json.Unmarshal([]byte(s), &gisVal); err != nil {
//		return
//	}
//	return
//}
//func newGisMultiPolygonStr(s string) (r string, err error) {
//	//ST_GeomFromText('MULTIPOLYGON(((10 10, 20 10, 20 20, 10 20, 10 10)), ((30 30, 40 30, 40 40, 30 40, 30 30)))', 4326)
//	var gisVal parDef.GisValWkt
//	var newWkt []string
//	if gisVal, err = jsonStrToGisValWkt(s); err != nil {
//		return
//	}
//	switch gisVal.Type {
//	case "polygon":
//		if _, newWkt, err = newGisWktValueCheck(gisVal, false); err != nil {
//			return
//		}
//		newWkt = []string{fmt.Sprintf("(%v)", newWkt[0])}
//	case "multiPolygon":
//		if _, newWkt, err = newGisWktValueCheck(gisVal, false); err != nil {
//			return
//		}
//	}
//	r = fmt.Sprintf("ST_GeomFromText('MULTIPOLYGON(%v)',%v)", strings.Join(newWkt, ","), gisVal.SRid)
//	return
//}
//func newGisGeometryStr(s string) (r string, err error) {
//	//ST_GeomFromText('GEOMETRYCOLLECTION(POINT(10 10), LINESTRING(20 20, 30 30), POLYGON((40 40, 50 40, 50 50, 40 50, 40 40)))', 4326)
//	var gisVal parDef.GisValWkt
//	var newWkt []string
//	var prefix string
//	if gisVal, err = jsonStrToGisValWkt(s); err != nil {
//		fmt.Println("-------err:", err)
//		return
//	}
//	if prefix, newWkt, err = newGisWktValueCheck(gisVal, false); err != nil {
//		return
//	}
//	r = fmt.Sprintf("ST_GeomFromText('%v(%v)',%v)", prefix, strings.Join(newWkt, ","), gisVal.SRid)
//	return
//}
//func newSpecialGisSubType(s string, v parDef.ColMetaMapS) (r string, err error) {
//	if len(s) == 0 || strings.EqualFold(s, "<entry>") || strings.EqualFold(s, "<null>") {
//		r = "NULL"
//		return
//	}
//	defer func() {
//		if err != nil {
//			err = ref.ErrAddPrintf("newSpecialGisSubType", err)
//		}
//	}()
//	switch strings.ToUpper(v.Type.ColTypeMap) {
//	case "GEOMETRY", "GEOMETRYCOLLECTION", "GEOMCOLLECTION":
//		r, err = newGisGeometryStr(s)
//	case "POINT":
//		r, err = newGisPointStr(s)
//	case "MULTIPOINT":
//		r, err = newGisMultiPointStr(s)
//	case "LINESTRING":
//		r, err = newGisLinestringStr(s)
//	case "MULTILINESTRING":
//		r, err = newGisMultiLinestringStr(s)
//	case "POLYGON":
//		r, err = newGisPolygonStr(s)
//	case "MULTIPOLYGON":
//		r, err = newGisMultiPolygonStr(s)
//	}
//	return
//}
//func newSpecialTypeActive(lob bool, s string, v parDef.ColMetaMapS) (r string, err error) {
//	//details string
//	var event = "[newSpecialTypeActive]"
//	if len(newNullValueActive(lob, s, v.TypeBelong)) > 0 {
//		r = newNullValueActive(lob, s, v.TypeBelong)
//		return
//	}
//	switch {
//	case strings.EqualFold(v.TypeBelong, "time"):
//		r = fmt.Sprintf("'%v'", s)
//		return
//	case strings.EqualFold(v.TypeBelong, "timestamp"):
//		// MySQL不允许向timestamp数据类型中插入带时区的日期database error is Error 1292 (22007): Incorrect datetime value: '2024-09-26 11:27:28 +0800 08:00' for column 'V3' at row 1
//		r = fmt.Sprintf("'%v'", strings.TrimSpace(strings.Split(s, " +")[0]))
//		return
//	case strings.EqualFold(v.TypeBelong, "gis"):
//		if r, err = newSpecialGisSubType(s, v); err != nil {
//			err = ref.ErrAddPrintf(event, err)
//		}
//		return
//	default:
//		r = s
//		switch {
//		case strings.EqualFold(v.TypeBelong, "json") && lob:
//			r = fmt.Sprintf("%v", s)
//			return
//		default:
//			if !lob {
//				r = fmt.Sprintf("'%v'", s)
//				return
//			}
//		}
//	}
//	return
//}
//func manyRows(parameter parDef.Parameter, rowsData [][]*string) (manyRowsValue []string, lobManyRowsValue [][]*string, err error) {
//	for _, row := range rowsData {
//		if len(row) == 0 {
//			continue
//		}
//		var singleRowsValue []string
//		var newRow []*string
//		for _, v := range parameter.ExecInsert.Columns {
//			var rowSeq int
//		c: //处理源端和目标端得列序号不一致，但列名一致得情况
//			for seq, col := range parameter.ExecInsert.QueryCol {
//				if strings.EqualFold(col.ColumnName, v.ColumnName) {
//					rowSeq = seq
//					break c
//				}
//			}
//			var lockSchema, lockFunc string
//		l:
//			for _, col := range parameter.Object.LockCol.Column {
//				if strings.EqualFold(col, v.ColumnName) {
//					lockSchema = parameter.Object.Schema
//					lockFunc = parameter.Object.LockCol.LockFunc
//					break l
//				}
//			}
//			var modifyColVal string
//			if modifyColVal, err = newSpecialTypeActive(parameter.Object.LobLogo, specialCharacterEscape(row[rowSeq]), v); err != nil {
//				return
//			}
//			columnVal := newColNameLock(lockSchema, lockFunc, modifyColVal)
//			singleRowsValue = append(singleRowsValue, columnVal)
//			if strings.EqualFold(v.TypeBelong, "gis") && strings.Contains(parameter.ExecInsert.Prefix, "(?") { //gis类型 && 包含lob  && gis类型为null，因为ST_GeomFromText(?,?) 需要多追加一个null
//				if strings.EqualFold(*row[rowSeq], "<null>") {
//					newRow = append(newRow, row[rowSeq], row[rowSeq])
//				} else {
//					newRow = append(newRow, row[rowSeq])
//				}
//			} else {
//				newRow = append(newRow, row[rowSeq])
//			}
//		}
//		manyRowsValue = append(manyRowsValue, strings.Join(singleRowsValue, ","))
//		lobManyRowsValue = append(lobManyRowsValue, newRow)
//	}
//	ref.SetFinalizer(rowsData)
//	return
//}
//func (rows RowsF) InsertSql(parameter parDef.Parameter) (result global.Return, err error) {
//	var rowsData [][]*string
//	var manyRowsValue []string
//	var lobManyRowsValue [][]*string
//	switch parameter.Meta.(type) {
//	case [][]*string:
//		rowsData = parameter.Meta.([][]*string)
//	default:
//		err = ref.ErrAddPrintf("MySQL.InsertSql", errors.New(fmt.Sprintf("type not match. type is %v", reflect.TypeOf(parameter.Meta))))
//		return
//	}
//	if manyRowsValue, lobManyRowsValue, err = manyRows(parameter, rowsData); err != nil {
//		err = ref.ErrAddPrintf("MySQL.InsertSql", err)
//	}
//	if len(manyRowsValue) == 0 {
//		return
//	}
//	if strings.Contains(parameter.ExecInsert.Prefix, "(?") {
//		result.Result = lobManyRowsValue
//		return
//	}
//	insertSql := fmt.Sprintf("%v (%v)", parameter.ExecInsert.Prefix, strings.Join(manyRowsValue, "),("))
//	result.Result = &insertSql
//	return
//}
//func (rows RowsF) insertDataPare(parameter parDef.Parameter) (execSql any, err error) {
//	var setVariables = []string{"SET session unique_checks=0", "SET session foreign_key_checks=0"}
//	switch parameter.Meta.(type) {
//	case []*string:
//		var newExecSql []*string
//		for _, v := range setVariables {
//			newExecSql = append(newExecSql, &v)
//		}
//		for _, v := range parameter.Meta.([]*string) {
//			newExecSql = append(newExecSql, v)
//		}
//		execSql = newExecSql
//	case [][]*string:
//		execSql = parameter.Meta
//	default:
//		err = ref.ErrAddPrintf("insertDataPare", errors.New(fmt.Sprintf("type not match. type is %v", reflect.TypeOf(parameter.Meta))))
//		return
//	}
//	return
//}
//func (rows RowsF) Insert(parameter parDef.Parameter) (result global.Return, err error) {
//	var (
//		event   = "[Insert]"
//		execSql any
//	)
//	if execSql, err = rows.insertDataPare(parameter); err != nil {
//		err = ref.ErrAddPrintf("MySQL.Insert", err)
//		return
//	}
//	if result, err = newExecInsertSql(ExecSqlInputS{
//		Ss:           parameter,
//		Event:        event,
//		InsertSqlStr: execSql,
//		LobSwitch:    parameter.Object.LobLogo,
//		InsertPrefix: parameter.ExecInsert.Prefix,
//	}); err != nil {
//		err = ref.ErrAddPrintf("MySQL.Insert", err)
//		return
//	}
//	return
//}
